﻿@{
    Layout = null;
}

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script src="~/Content/BootstrapSouce/js/jquery.min.js"></script>
    <link href="~/Content/BootstrapSouce/css/bootstrap.min.css" rel="stylesheet" />

    <link href="~/Content/BootstrapSouce/css/H-ui.min.css" rel="stylesheet" />
    <script src="~/Content/EasyUI/js/common.js"></script>
    <script src="~/Content/EasyUI/js/jquery-easyui-1.2.6/jquery.easyui.min.js"></script>
    <title></title>
    <script>
        window.a = 1;
        function addborrower() {

            a++;
            $("#add").append('<div id="' + a + '" style="margin-top:20px;height:30px"><label class="form-label  col-xs-1 col-sm-2"><span class="c-red"></span>借款人员姓名：</label><div class="formControls col-xs-11 col-sm-9"><input type="text" style="width:200px" class="input-text" value="" placeholder="" id="" name="loan_Name"> <label class="form-label" style="display:inline;margin-left:5px">&nbsp;&nbsp;性别:&nbsp;&nbsp;<input type="radio" name="a"/>男<input type="radio" name="a" />女&nbsp;&nbsp;身份证号：</label><input type="text" style="width:200px" class="input-text" value="" placeholder="" id="" name="loan_IdCard"><label class="form-label " style="display:inline; margin-left:5px">电话：</label><input type="text" style="width:200px" class="input-text" value="" placeholder="" id="" name="loan_TEL">  <input type="button"  style="display:inline; margin-left:10px" class="btn btn-success" onclick="hide(' + a + ')" value="取消" /></div>   ')

        }
        function hide(x) {
            $("#" + x + "").remove();
        }
    </script>
</head>
<body>
    
    <h2 style="text-align:center">资产登记</h2>
    <div class="row cl">
        <label class="form-label col-xs-1 col-sm-2"><span class="c-red"></span>借款人员姓名：</label>
        <div class="formControls col-xs-11 col-sm-9">
            <input type="text" style="width:200px" class="input-text" id="" name="loan_Name">
            <label class="form-label" style="display:inline;margin-left:0px">身份证号：</label>
            <input type="text" style="width:200px" class="input-text" value="" placeholder="" id="" name="loan_IdCard">
            <label class="form-label " style="display:inline; margin-left:0px">性别：</label>
            <input type="radio" class="" name="a" /><label class="form-label " style="display:inline; margin-left:0px">男</label><input type="radio" name="a" /><label class="form-label " style="display:inline; margin-left:0px">女</label>
            <label class="form-label " style="display:inline; margin-left:0px">电话：</label>

            <input type="text" style="width:200px" class="input-text" value="" placeholder="" id="" name="loan_TEL">
            <input type="button" class="btn btn-success" onclick="addborrower()" value="添加借款人" />

        </div>
    </div>
    <div class="row cl" id="add">

    </div>

    <div class="row cl" style="margin-top:20px">
        <label class="form-label col-xs-2 col-sm-2"><span class="c-red"></span>联系人：</label>
        <div class="formControls col-xs-10 col-sm-7">
            <input type="text" class="input-text" placeholder="输入随时可以联系的人" id="" name="loan_Contacts" onkeyup="funvalidate()" ><span id="spanemailaddr" style="color:red"></span>
        </div>
    </div>
    <div class="row cl" style="margin-top:20px">
        <label class="form-label col-xs-4 col-sm-2"><span class="c-red"></span>联系电话：</label>
        <div class="formControls col-xs-8 col-sm-7">
            <input type="text" class="input-text" value="" placeholder="请输入联系电话" id="" name="loan_ContactsTEL" onkeyup="funvalidateTEL()"><span id="TEl" style="color:red"></span>

        </div>
    </div>
    <div class="row cl" style="margin-top:20px">
        <label class="form-label col-xs-4 col-sm-2"><span class="c-red"></span>贷款年限：</label>
        <div class="formControls col-xs-8 col-sm-7">
            <input type="text" class="input-text" value="" placeholder="输入贷款年限" id="" name="surplus_Years" onkeyup="funvalidateYears()"><span id="Years" style="color:red"></span>

        </div>
    </div>
    <div class="row cl" style="margin-top:20px">
        <label class="form-label col-xs-4 col-sm-2"><span class="c-red"></span>贷款额度：</label>
        <div class="formControls col-xs-8 col-sm-7">
            <input type="text" class="input-text" value="" placeholder="" id="" name="basic_Quota" onkeyup="funvalidateQuota()"><span id="Quota" style="color:red"></span>

        </div>
    </div>
    <div class="row cl" style="margin-top:20px">
        <label class="form-label col-xs-5 col-sm-2">建成年代：</label>
        <div class="formControls col-xs-7 col-sm-7">
            <input type="text" class="input-text" value="" placeholder="" id="" name="house_Time" onkeyup="funvalidateTime()"><span id="Time" style="color:red"></span>

        </div>
    </div>
    <div class="row cl" style="margin-top:20px">
        <label class="form-label col-xs-5 col-sm-2">建成年代来源：</label>
        <div class="formControls col-xs-7 col-sm-7">
            <span class="select-box">
                @Html.DropDownList("yers_Source", null, new { @class = "select" })
            </span>

        </div>
    </div>

    <div class="row cl" style="margin-top:20px">
        <label class="form-label col-xs-4 col-sm-2">房屋坐落：</label>
        <div class="formControls col-xs-8 col-sm-7">
            <input type="text" class="input-text" value="" placeholder="" id="" name="house_Located">

        </div>
    </div>
    <div class="row cl" style="margin-top:20px">
        <label class="form-label col-xs-4 col-sm-2">房屋用途：</label>
        <div class="formControls col-xs-8 col-sm-7">
            <span class="select-box">
                @Html.DropDownList("house_Purpose", null, new { @class = "select" })
            </span>
        </div>
    </div>

    <div class="row cl" style="margin-top:20px">
        <label class="form-label col-xs-5 col-sm-2">报告类型：</label>

        <div class="formControls col-xs-8 col-sm-7">
            <span class="select-box">
                @Html.DropDownList("presentation_Type", null, new { @class = "select" })
            </span>
        </div>

    </div>
    <div class="row cl" style="margin-top:20px">
        <label class="form-label col-xs-5 col-sm-2">评估受理：</label>
        <div style="margin-top:0px">

            @foreach (var i in ViewBag.assessment)
            {
                <input id="Checkbox1" type="checkbox" class="check-box" name="assessment" value="@i.Dictionary_IdNumber" />@i.dictionary_Name
            }

        </div>
    </div>
    <div class="row cl" style="margin-top:20px">
        <label class="form-label col-xs-4 col-sm-2">所属部门：</label>
        <div class="formControls col-xs-8 col-sm-7" style="width:200px">
            <span class="select-box">
                @Html.DropDownList("the_Department", null, new { @class = "select" })

            </span>

        </div>


    </div>
    <div class="row cl" style="margin-top:20px">
        <label class="form-label col-xs-4 col-sm-2">现场勘察人员：</label>

        <div class="formControls col-xs-8 col-sm-7" style="width:200px">
            <span class="select-box">
                
                @Html.DropDownList("survey", null, new { @class = "select" })
            </span>

        </div>

    </div>
    <div class="row cl" style="margin-top:20px">
        <label class="form-label col-xs-5 col-sm-2">估价员：</label>

        <div class="formControls col-xs-6 col-sm-7" style="width:200px">
            <span class="select-box">
                @Html.DropDownList("evaluation", null, new { @class = "select" })

            </span>

        </div>

    </div>
    <div class="row cl" style="margin-top:20px">
        <label class="form-label col-xs-5 col-sm-2">抵押物管理点：</label>
        <div class="formControls col-xs-7 col-sm-7">

            <label>海淀部</label>
        </div>
    </div>
    <button class="btn btn-success" style="margin-left:43%;margin-top:30px" onclick="addbasic()">提交</button>


</body>
</html>
<style>
    .form-label {
        margin-left: 100px;
    }
</style>
<script>
    //联系人验证
    function  funvalidate()
    {
        var loan_Contacts = $("[name='loan_Contacts']").val();
        var reg = /^[\u4e00-\u9fa5]{0,}$/;
        if (loan_Contacts == "") {
            document.getElementById("spanemailaddr").innerHTML = "联系人不能为空";
            $("[name='loan_Contacts']").css("border", "3px solid red");
            return false;
        }
        else if (!reg.test(loan_Contacts))
        {
            document.getElementById("spanemailaddr").innerHTML = "只能输入汉字";
            $("[name='loan_Contacts']").css("border", "3px solid red");
            return false;
        }
        else {
            document.getElementById("spanemailaddr").innerHTML = "";
            $("[name='loan_Contacts']").css("border", "3px solid green");
            return true;
        }
    }

    //手机号验证
    function  funvalidateTEL()
    {
        var loan_ContactsTEL = $("[name='loan_ContactsTEL']").val();
        var reg = /^1[3|4|5|8]\d{9}$/;
        if(loan_ContactsTEL=="")
        {
            document.getElementById("TEl").innerHTML = "手机号不能为空";
            $("[name='loan_ContactsTEL']").css("border", "3px solid red");
            return false;
        }
        else if(!reg.test(loan_ContactsTEL))
        {
            document.getElementById("TEl").innerHTML = "请输入正确的手机号码格式";
            $("[name='loan_ContactsTEL']").css("border", "3px solid red");
            return false;
        }
        else
        {
            document.getElementById("TEl").innerHTML = "";
            $("[name='loan_ContactsTEL']").css("border", "3px solid green")
            return true;
        }
    }

    function funvalidateYears()
    {
        var ss = $("[name='surplus_Years']").val();
        var reg = /^[0-9]*$/;
        if (ss == "") {
            document.getElementById("Years").innerHTML = "不能为空";
            $("[name='surplus_Years']").css("border", "3px solid red");
            return false;
        }
        else if (!reg.test(ss)) {
            document.getElementById("Years").innerHTML = "请输入数字";
            $("[name='surplus_Years']").css("border", "3px solid red");
            return false;
        }
        else {
            document.getElementById("Years").innerHTML = "";
            $("[name='surplus_Years']").css("border", "3px solid green")
            return true;
        }
    }
    //贷款验证
    function  funvalidateQuota()
    {
        var loan_ContactsTEL = $("[name='basic_Quota']").val();
        var reg = /^[0-9]*$/;
        if (loan_ContactsTEL == "") {
            document.getElementById("Quota").innerHTML = "不能为空";
            $("[name='basic_Quota']").css("border", "3px solid red");
            return false;
        }
        else if (!reg.test(loan_ContactsTEL)) {
            document.getElementById("Quota").innerHTML = "请输入数字";
            $("[name='basic_Quota']").css("border", "3px solid red");
            return false;
        }
        else {
            document.getElementById("Quota").innerHTML = "";
            $("[name='basic_Quota']").css("border","3px solid green")
            return true;
        }
    }

    function funvalidateTime()
    {
        var loan_ContactsTEL = $("[name='house_Time']").val();
        var reg = /^[0-9]*$/;
        if (loan_ContactsTEL == "") {
            document.getElementById("Time").innerHTML = "不能为空";
            $("[name='house_Time']").css("border", "3px solid red");
            return false;
        }
        else if (!reg.test(loan_ContactsTEL)) {
            document.getElementById("Time").innerHTML = "请输入数字";
            $("[name='house_Time']").css("border", "3px solid red");
            return false;
        }
        else {
            document.getElementById("Time").innerHTML = "";
            $("[name='house_Time']").css("border", "3px solid green")
            return true;
        }
    }

     
    
    function addbasic()
    {
        
        var name = new Array();
        $("[name='loan_Name']").each(function(){
            name.push($(this).val());
        })
        var Tel = new Array();
        $("[name='loan_TEL']").each(function () {
            Tel.push($(this).val());
        })
        var Card = new Array();
        $("[name='loan_IdCard']").each(function () {
            Card.push($(this).val());
        })
        var loan_Contacts = $("[name='loan_Contacts']").val();
        var loan_ContactsTEL = $("[name='loan_ContactsTEL']").val();
        var surplus_Years = $("[name='surplus_Years']").val();
        var basic_Quota = $("[name='basic_Quota']").val();
        var house_Time = $("[name='house_Time']").val();
        var yers_Source = $("[name='yers_Source']").val();
        var house_Located = $("[name='house_Located']").val();
        var house_Purpose = $("[name='house_Purpose']").val();
        var presentation_Type = $("[name='presentation_Type']").val();
        var assessment = "";
        $("[name='assessment']:checked").each(function () {
            assessment+=($(this).val())+",";
        })
        assessment = assessment.substr(0, assessment.length - 1);
        var the_Department = $("[name='the_Department']").val();
        var survey = $("[name='survey']").val();
        var evaluation = $("[name='evaluation']").val();
        var Basic_info = { loan_Contacts: loan_Contacts, loan_ContactsTEL: loan_ContactsTEL, surplus_Years: surplus_Years, basic_Quota: basic_Quota, house_Time: house_Time, yers_Source: yers_Source, house_Located: house_Located, house_Purpose: house_Purpose, presentation_Type: presentation_Type, assessment: assessment, the_Department: the_Department, survey: survey, evaluation: evaluation ,basic_CreatePeople:localStorage.getItem("id")};

        $.ajax({
            url: "http://localhost:63805/api/Basic_Info",
            data: JSON.stringify({ loan_Name: name, loan_TEL: Tel, loan_IdCard: Card, Basic_Info: Basic_info }),
            dataType: "json",
            type: "post",
            contentType: "application/json",
            success: function (obj) {
                if(obj>0)
                {
                    alert('添加成功');
                    location.href = '/basic/basic_show?id=' + localStorage.getItem("id");
                    //self.parent.$("#tabs").tabs('select', '我的立项');在新增的tabs情况下，此代码可以让’我的立项‘tab显示
                    //var tab = $("#tabs").tabs('getSelected');获取当前的tab对象
                   // RefreshTab(tab);执行刷新（当前tab对象）
                    
                    //location.href = '/Basic/Basic_show/'+localStorage.getItem("id");
                }
                else
                {
                    alert('添加失败');
                }
            }
        })
    }
    ///刷新方法
    //function RefreshTab(currentTab) {
    //    var url = $(currentTab.panel('options')).attr('href');
    //    $('#tabs').tabs('update', {
    //        tab: currentTab,
    //        options: {
    //            href: url
    //        }
    //    });
    //    currentTab.panel('refresh');
    //}
</script>
